package com.commerceerp.system.api.winit;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.commerceerp.system.api.winit.model.Product;
import com.commerceerp.system.entity.ShopWish;
import com.commerceerp.system.util.ApiResult;
import com.commerceerp.system.util.StringUtils;
import org.junit.Test;

import java.util.*;


public class CalcDeliveryFeeTest{

    /**
     * 获取仓库信息
     */
    @Test
    public void queryWarehouse() {
        JSONObject data = new JSONObject();
        data.put("country", "US");
        data.put("region", "FL");
        data.put("city", "coral springs");
        List<Product> productList = new ArrayList<Product>();
        Product pd = new Product();
        pd.setProductCode("a50066-W-black");
        pd.setProductNum("3");
        pd.setSpecification("");
        productList.add(pd);
        data.put("productList", productList);
        data.put("warehouseCode", "DE0001");
        data.put("zipCode", "33071");
        data.put("winitProductCode", "");
        BaseHandler test = new BaseHandler();
        String result = test.doQuery("wh.outbound.calcDeliveryFee",data);
        JSONObject json = JSONObject.parseObject(result);
        JSONArray array  = (JSONArray)json.get("data");

        List list = new ArrayList();

        for(int i=0;i<array.size()-4;i++){
            JSONObject feeList  = (JSONObject)array.get(i);
            System.out.println("----------------------------------------------");
            System.out.println("totalFeeUSD: "+feeList.getString("totalFeeUSD"));
            System.out.println("ISOCode: "+feeList.getString("ISOCode"));
            System.out.println("deliveryWay: "+feeList.getString("deliveryWay"));
            System.out.println("deliveryWayCode: "+feeList.getString("deliveryWayCode"));
            System.out.println("logisticsTime: "+feeList.getString("logisticsTime"));
            JSONArray fees = (JSONArray)feeList.get("FeeList");
            for(int j=0;j<fees.size();j++){
                JSONObject obj = (JSONObject)fees.get(j);
                String feeName = obj.getString("feeName");
                String feeNumber = obj.getString("feeNumber");
                //System.out.println("feeName: "+feeName);
                //System.out.println("feeNumber: "+feeNumber);

            }
        }
    }
}
